<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-7-20
 * Time: 上午11:09
 */

namespace ActionsHttp;

use Data\Statistics_restaurant_day_turnover_DAO;

class RestaurantStatistics extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 商铺id
        $restaurant_id = $_SESSION[RESTAURANT_ID];
        $restaurant_id = 1;

//        // 今天零点时间戳
//        $today_time = strtotime(date('Ymd'));
//        // 昨天零点时间戳
//        $yesterday_time = $today_time-86400;
//        // 昨天日期
//        $yesterday_date = date("Y-m-d",$yesterday_time);
        $date = $this->data[DATE];

        $statistics_record = Statistics_restaurant_day_turnover_DAO::getRecord($restaurant_id,$date);
        if (!$statistics_record) {
            return $this->SendErrMsg("没有数据");
        }

        $statistics_info = $statistics_record->getArray();
        $statistics_info[FOOD_SALED_COUNT] = json_decode($statistics_info[FOOD_SALED_COUNT],true);
        $statistics_info[FOOD_SALED_PRICE] = json_decode($statistics_info[FOOD_SALED_PRICE],true);

        // 返回数据
        $this->setValue(STATISTICS_INFO,$statistics_info);
        $this->ResponseDataToCurrentClient();
    }
}